import { downloadByUrl, getNameByOwnUrl } from '@/utils/util'
import { Empty, Typography } from 'antd'
import { ITableData } from '../Contract/types'
import { QualityOrderVO } from './types'

export const useFormReply = (): IItemArray[] => {
  return [
    {
      label: 'QC人员',
      name: 'qualityInspector',
      type: 'Input',
      rules: [
        {
          required: true,
          message: '请输入QC人员',
        },
      ],
    },
    {
      name: 'replyQualityTime',
      label: '回复QC时间',
      type: 'DatePicker',
      placeholder: '请选择回复QC时间',
      rules: [
        {
          required: true,
          message: '请选择回复QC时间',
        },
      ],
    },
  ]
}
export const useFormRun = (): IItemArray[] => {
  return [
    {
      name: 'actualQualityTime',
      label: '实际QC时间',
      type: 'DatePicker',
      placeholder: '请选择实际QC时间',
      rules: [
        {
          required: true,
          message: '请选择实际QC时间',
        },
      ],
    },
    {
      name: 'passed',
      label: '是否通过',
      type: 'Radio',
      option: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
      rules: [
        {
          required: true,
          message: '请选择是否通过',
        },
      ],
    },
    {
      name: 'remark',
      label: '备注',
      type: 'TextArea',
      placeholder: '请输入备注',
      config: {
        showCount: true,
        maxLength: 100,
      },
    },
    {
      name: 'fileId',
      label: 'QC报告',
      type: 'UploadFile',
      config: {
        showCount: true,
        maxLength: 100,
      },
    },
  ]
}
export const useFormCon = ({ CurrentInfo }: { CurrentInfo: Record<string, any> }): IItemArray[] => {
  return [
    {
      label: '实际QC时间',
      type: 'Custom',
      slot: CurrentInfo?.actualQualityTime || '-',
    },
    {
      label: '是否通过',
      type: 'Custom',
      slot: CurrentInfo?.passed == 1 ? '是' : '否',
    },
    {
      label: '备注',
      type: 'Custom',
      slot: CurrentInfo?.remark || '-',
    },
    {
      label: 'QC报告',
      type: 'Custom',
      slot: CurrentInfo?.fileId
        ? CurrentInfo?.fileId.split(',')?.map((item: any) => {
            return (
              <div key={item}>
                <Typography.Link onClick={() => downloadByUrl(item)}>{getNameByOwnUrl(item)}</Typography.Link>
              </div>
            )
          })
        : '-',
    },
  ]
}
